package com.eso.haBank.domain

import groovy.transform.ToString
import groovy.transform.EqualsAndHashCode

@EqualsAndHashCode
@ToString(includeNames = true, includeFields = false, excludes = 'metaClass,beforeInsert,beforeUpdate')
class Employee implements Serializable {

    String userId;
    String userName;
    String userPwd;

    Integer userSex;//性别
    String userIcon;//用户头像

    String userRole;//用户角色
    String dataRole;//数据权限
    Integer userStatus = 1;//用户状态：0-停用，1-启用

    String comment;

    String obligateField1;//预留字段1
    String obligateField2;//预留字段2
    String obligateField3;//预留字段3

    String createUser;
    Date createTime;
    String updateUser;
    Date updateTime;

    static belongsTo = [department: Department]

    static constraints = {
        userId(blank: false, maxSize: 10, unique: true)
        userName(blank: false, maxSize: 50)
        userPwd(blank: false, maxSize: 200)
        userRole(blank: false, maxSize: 5)
        dataRole(blank: false, maxSize: 2)
        userStatus(inList: [1, 0])

        userSex(inList: [0, 1, 9])
        userIcon(nullable: true, maxSize: 500)

        department()

        comment(nullable: true, maxSize: 200)

        obligateField1(nullable: true, maxSize: 500)
        obligateField2(nullable: true, maxSize: 500)
        obligateField3(nullable: true, maxSize: 500)

        createUser(blank: false, maxSize: 10)
        createTime(nullable: true)
        updateUser(blank: false, maxSize: 10)
        updateTime(nullable: true)
    }

    def beforeInsert = {
        createTime = new Date()
        updateTime = new Date()
    }

    def beforeUpdate = {
        updateTime = new Date()
    }

    static mapping = {
        table 'sys_employee'
        version false
    }
}
